<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script src="js/vue2.js"></script>
</head>

<body>
    <div id="app">
        <h2>{{message}}</h2>
        <p>{{count}}</p>
        <button @click="count++">++</button>
        <P>count的平方:{{square}}</P>
    </div>

    <script>
        //创建Vue实例,得到 ViewModel
        let vm = new Vue({
            el: '#app',
            data: {
                message: '你好',
                count: 1,
            },
            methods: {

            },
            computed: {
                //计算属性函数。必须要有适图值
                //第一次进来会执行，并且依赖的值。发生了改变，他也会再次执行
                square() {
                    return this.count * this.count
                }
            }
        })
    </script>
</body>

</html>